#pragma once

#ifndef INPUTHANDLER_H
#define INPUTHANDLER_H

#include <Windows.h>
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>

#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

class InputHandler // InputHandler declaration
{
private:
	HWND hWnd;									// handle to window using directx
	IDirectInput8* dInput;						// DirectInput object
	IDirectInputDevice8* mouse;					// mouse device
	IDirectInputDevice8* keyboard;				// keyboard device
	unsigned char keyboardState[256];			// current keyboard state
	unsigned char previousKeyboardState[256];	// keyboard state from last frame
	DIMOUSESTATE2 mouseState;					// current mouse state
	DIMOUSESTATE2 previousMouseState;			// previous mouse state
	POINT mousePosition;						// current mouse position
	POINT previousMousePosition;				// previous mouse position
public:
	InputHandler(HINSTANCE hInstance, HWND hWnd);	// constructor
	virtual ~InputHandler();						// destructor 
	void poll();									// updates state value in InputHandler
	bool isKeyDown(unsigned char key) const;		// check if key is down
	bool wasKeyDown(unsigned char key) const;		// check if key was down
	DIMOUSESTATE2 getCurrentMouse() const			// gets current mouse state
	{
		return mouseState;
	}
	DIMOUSESTATE2 getPreviousMouse() const			// gets previous mouse state
	{
		return previousMouseState;
	}
	POINT getCurrentMousePos() const { return mousePosition; }			// gets current mouse position
	POINT getPreviousMousePos() const { return previousMousePosition; }	// gets previous mouse position
};

#endif